package com.dk.jwzx;

import com.dk.jwzx.bean.Student;
import com.dk.jwzx.bean.Subject;
import com.dk.jwzx.reptile.Reptile;
import com.dk.jwzx.reptile.student.CquptStudentReptile;
import com.dk.jwzx.reptile.subject.CquptSubjectReptile;
import com.dk.jwzx.reptile.week.CquptWeekReptile;

import java.util.List;
import java.util.Map;

public class JwzxImpl implements Jwzx,JwzxHost {

    private static Reptile subjectReptile=new CquptSubjectReptile();
    private static Reptile studentReptile=new CquptStudentReptile();
    private static Reptile weekReptile=new CquptWeekReptile();

    @Override
    public void init() {
        subjectReptile.init();
        studentReptile.init();
        weekReptile.init();
    }

    @Override
    public Student getStudentInfo(String stuId) {
        return studentReptile.crawling(CQUPT_STUDENT_HOST +"?searchKey="+stuId);
    }

    @Override
    public Map<Integer, List<Subject>> getStudentSubjects(String stuId) {
        return subjectReptile.crawling(CQUPT_SUBJECT_HOST +"?xh="+stuId);
    }

    @Override
    public int getWeek() {
        return weekReptile.crawling(CQUPT_WEEK_HOST);
    }
}
